import yaml
import os

class ConfigLoader:
    def __init__(self, config_path='./config/config.yml'):
        self.config_path = config_path
        self.config = self._load_config()

    def _load_config(self):
        """Load configuration from YAML file"""
        try:
            with open(self.config_path, 'r', encoding='utf-8') as f:
                return yaml.safe_load(f)
        except FileNotFoundError:
            raise FileNotFoundError(f"Configuration file not found at {self.config_path}")
        except yaml.YAMLError as e:
            raise ValueError(f"Error parsing configuration file: {str(e)}")

    @property
    def server_url(self):
        return self.config['server']['url']

    @property
    def api_key(self):
        return self.config['server']['api_key']

    @property
    def model_name(self):
        return self.config['model']['name']

    @property
    def stream_enabled(self):
        return self.config['model']['stream']

    def get_headers(self):
        return {
            "Content-Type": "application/json",
            "Authorization": f"Bearer {self.api_key}"
        } 